
from x_com import xport_core
from x_com import source_api
from x_com.import_api import ecommerce_data_source_service_0_0_1
import x_com_lib

logger = xport_core.getLogger()

class EcommerceDataSubscriberService:
    
  async def on_init(self):
    logger.info("on_init...")

  async def on_finalize(self):
    logger.info("on_finalize...")

  # SubscribeData
  async def subscribe_data(self, ctx: xport_core.Context):

    subscibe_info = x_com_lib.PySubscribeTopicInfo()

    subscibe_info.tag = [] 

    subscibe_info.topic = "ProductSale"
    logger.info(f"节点 订阅 ProductSale 事件...")
    x_com_lib.stream.dxc_subscribe_topic(subscibe_info)

    subscibe_info.topic = "UserRegister"
    logger.info(f"节点 订阅 UserRegister 事件...")
    x_com_lib.stream.dxc_subscribe_topic(subscibe_info)


    subscibe_info.topic = "UserLogin"
    logger.info(f"节点 订阅 UserLogin 事件...")
    x_com_lib.stream.dxc_subscribe_topic(subscibe_info)


    await ecommerce_data_source_service_0_0_1.subscribe_data()

